<template>
  <div>
    <el-dialog
      title="修改设备"
      :visible="dialogVisible3"
      width="30%"
      @close="handleClose"
    >
      <el-form ref="ruleForm" label-width="100px" class="demo-ruleForm" :model="ruleForm">
        <el-form-item label="机器编号:">
          {{ amendType.innerCode }}
        </el-form-item>

        <el-form-item label="供货时间:">
          {{ amendType.lastSupplyTime }}
        </el-form-item>
        <el-form-item label="设备类型:">
          {{ amendType.type.name }}
        </el-form-item>
        <el-form-item label="设备容量:">
          {{ amendType.type.channelMaxCapacity }}
        </el-form-item>
        <el-form-item label="设备点位:">
          <el-select v-model="ruleForm.id">
            <el-option v-for="item in amendSearchList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="合作商:" prop="ownerName">
          {{ amendType.ownerName }}
        </el-form-item>
        <el-form-item label="所属区域:" prop="">
          {{ amendType.region.name }}
        </el-form-item>
        <el-form-item label="设备地址:">
          {{ amendType.node.name }}
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="amendVendingSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getAmendNodeSearchAPI, getAmendVendingNodeAPI } from '@/api/vmIndex'
export default {
  name: 'DialogAmendType',
  components: {},
  props: {
    dialogVisible3: {
      type: Boolean,
      default: false
    },
    amendType: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      ruleForm: {
        id: ''
      },
      rules: {},
      pageIndex: 1,
      pageSize: 1000,
      amendSearchList: []
    }
  },
  computed: {
    // id() {
    //   return this.amendSearchList.filter(item => item.id === this.ruleForm.id)
    // }
  },
  watch: {},
  created() {
    this.getAmendNodeSearch()
  },
  methods: {
    handleClose() {
      this.$emit('update:dialogVisible3', false)
    },
    // 点位搜索
    async getAmendNodeSearch() {
      const { data } = await getAmendNodeSearchAPI(this.pageIndex, this.pageSize)
      console.log(data)
      this.amendSearchList = data.currentPageRecords
    },
    // 修改售货机点位
    async amendVendingSubmit() {
      await getAmendVendingNodeAPI(this.amendType.id, this.amendType.nodeId)
    }
  }
}
</script>

<style scoped>

</style>
